var app = getApp();
var https = "https://www.moreclub.cn/";
var htp = 'http://more-image.oss-cn-beijing.aliyuncs.com/pinzuominiapp/pinzuoall_bg_';
var http1 = 'http://10.150.7.248:8001/'
var add0 = function (m) {
  return m < 10 ? '0' + m : m
}
var time = function (timestamp) {
  var time = new Date(timestamp);
  // var y = time.getFullYear();
  var m = time.getMonth() + 1;
  var d = time.getDate();
  var h = time.getHours();
  var mm = time.getMinutes();
  // var s = time.getSeconds();
  // return y + '-' + add0(m) + '-' + add0(d) + ' ' + add0(h) + ':' + add0(mm) + ':' + add0(s);
  return add0(m) + '月' + add0(d) + '日' + ' ' + add0(h) + ':' + add0(mm)
}

Page({
  data: {
    totallist: [],
    src: [htp + '6_o.png', htp + '4_y.png', htp + '3_r.png', htp + '2_p.png', htp + '1_g.png', htp + '5_b.png'],
    border: ['1px solid #f8a52c', '1px solid #f6e33e', '1px solid #ef4444', '1px solid #8c32d6', '1px solid #23c114', '1px solid #08cee1'],
    icon: ['pinzuo_6_pgz_black@2x.png', 'pinzuo_4_llt_black@2x.png', 'pinzuo_3_wyx_black@2x.png', 'pinzuo_2_qhd_black@2x.png', 'pinzuo_1_bgm_black@2x.png', 'pinzuo_5_bsh_black@2x.png'],
    icon2: ['buyuadrink_white@2x.png', 'cocktail_white@2x.png', 'beerbrew_white@2x.png', 'wine_white@2x.png', 'whiskey_white@2x.png', 'importbeer_white@2x.png', 'champagne_white@2x.png', 'brandy_white@2x.png', 'saki_white@2x.png'],
    tent: ['拼个座', '聊撩天', '玩游戏', '求回答', '帮个忙', '憋说话'],
    cont: ['', '鸡尾酒', '精酿啤酒', '葡萄酒', '威士忌', '进口啤酒', '香槟', '白兰地', '清酒'],
    holder: ['一个人喝酒超级无聊，想找好玩朋友拼个座，带我飞。', '聊音乐，电影，酒...认识有趣的你！', '急！玩游戏缺人，求旁边的帅哥靓女加入~', '城市小白，求土著支招好吃的好玩的去处！', '遇见生活小难题，求大神支招！', '开车堵，上班老板不酷，回家生活不酷，憋着难受，这里说点酷的！']

  },
  onLoad: function (options) {
    var that = this;
    var mid = options.mid

     wx.request({
       url: https + 'v2/signinter/open/merchantInters?mid='+mid+'&pn=0',
       success:function(res){
         console.log(res)
         var datalist = res.data.data
         let dataArr = []

         for (var i = 0; i < datalist.length; i++) {

           var p = datalist[i].userThumb;
           var name = datalist[i].nickName;
           // var day = datalist[i].day;
           var age = datalist[i].age;
           var gender = datalist[i].gender;
           var merchantName = datalist[i].merchantName;
           var mid = datalist[i].mid;
           var uid1 = datalist[i].uid;
           var cont = datalist[i].content;
           var gift = datalist[i].gift;
           var sid = datalist[i].sid;
           var type1 = datalist[i].type;
           var exprise = datalist[i].exprise;
           if (datalist[0].timestamp.length == 10) {
             var timestamp = (datalist[i].timestamp)*1000;
            
           }else{
             var timestamp = datalist[i].timestamp
           }

           if (type1 == 5 || type1 == null) {
             var txt = 0;
           }
           if (type1 == 3) {
             var txt = 1;
           }
           if (type1 == 6) {
             var txt = 2;
           }
           if (type1 == 4) {
             var txt = 3;
           }
           if (type1 == 1) {
             var txt = 4;
           }
           if (type1 == 2) {
             var txt = 5;
           }

           

           time(timestamp)
           var dataTime = time(timestamp)


           let obj = {}
           obj.height = 0,
             obj.pic = p || null,
             obj.name = name,
             obj.age = age,
             obj.uid1 = uid1,
             obj.gender = gender,
             obj.mid = mid,
             obj.gift = gift,
             obj.txt = txt,
             obj.sid = sid,
             obj.exprise = exprise,
             obj.content = cont,
             obj.merchantName = merchantName,
             obj.dataTime = dataTime,
             dataArr.push(obj)

         }

         that.setData({
           dataArr: dataArr
         })
       }
     }) 
  }  
})